/*
 * @Author: ZhaoZhiqi
 * @Date: 2022-08-09 09:47:21
 * @LastEditors: ZhaoZhiqi
 * @LastEditTime: 2022-12-13 10:26:50
 * @Description: 角色管理
 * @FilePath: \tuanfeng-admin-front\src\api\role.ts
 */
import requset from "../utils/request"

/**
 * @description: 获取角色列表
 * @param {number} pageNo 默认1
 * @param {number} pageSize 默认10
 * @param {string} name 角色名称，模糊查询
 * @return {*}
 */
export const getRoleListAPI = (data: any) => {
    return requset('role/getRolesPageByParams', 'GET', data)
}

/**
 * @description: 获取全部角色列表
 * @return {*}
 */
export const getAllRoleListAPI = () => {
    return requset('role/getAllRole', 'GET', {})
}

/**
 * @description: 新建角色
 * @param {string} name 名称
 * @param {string} remark 备注
 * @param {Array<number>} roleMenus 角色菜单
 * @return {*}
 */
export const addRoleAPI = (data: any) => {
    return requset('role/addRole', 'POST', data)
}

/**
 * @description: 更新角色
 * @param {number} id id
 * @param {string} name 名称
 * @param {string} remark 备注
 * @param {Array<number>} roleMenus 角色菜单
 * @return {*}
 */
export const updateRoleAPI = (data: any) => {
    return requset('role/updateRole', 'POST', data)
}

/**
 * @description: 删除角色
 * @param {number} id id
 * @return {*}
 */
export const deleteRoleAPI = (data: any) => {
    return requset(`role/deleteRole/${data.id}`, 'GET', data)
}

/**
 * @description: 查询所有菜单
 * @return {*}
 */
export const getAllMenusListAPI = () => {
    return requset(`/menu/getMenusWithChildAndBtns`, 'GET', {})
}

/**
 * @description: 根据id查询菜单
 * @param {number} id id
 * @return {*}
 */
export const getRoleMenusAPI = (data: any) => {
    return requset(`role/getRoleMenuByRid/${data.id}`, 'GET', {})
}